package pl.softech.gpw.candles.editor;

import java.awt.Rectangle;

import pl.softech.gpw.candles.Candle;
import pl.softech.gpw.model.FInstrument;


public enum PaletteCandelstickWidgets {
    
    BLACK_BODY(createBlackBody()),
    WHITE_BODY(createWhiteBody()),
    DOJI(createDoji());

    private final CandlestickWidget widget;

    private PaletteCandelstickWidgets(CandlestickWidget widget) {
        this.widget = widget;
    }
    
    public static double point2pixel() {
        CandlestickWidget widget = PaletteCandelstickWidgets.WHITE_BODY.widget;
        Rectangle wbounds =  widget.getWidget().getBounds();
        return widget.getCandlestick().getLen() / wbounds.getHeight();
    }
    
    public CandlestickWidget widget() {
        return widget.clone();
    }
    
    private static CandlestickWidget createBlackBody() {
        FInstrument fInstrument = new FInstrument();
        fInstrument = new FInstrument();
        fInstrument.setLow(10);
        fInstrument.setOpen(50);
        fInstrument.setClose(30);
        fInstrument.setHigh(70);
        Candle widget = new Candle(fInstrument);
        return new CandlestickWidget(widget, null);
    }
    
    private static CandlestickWidget createWhiteBody() {
        FInstrument fInstrument = new FInstrument();
        fInstrument = new FInstrument();
        fInstrument.setLow(10);
        fInstrument.setOpen(30);
        fInstrument.setClose(50);
        fInstrument.setHigh(70);
        Candle widget = new Candle(fInstrument);
        return new CandlestickWidget(widget, null);
    }
    
    private static CandlestickWidget createDoji() {
        FInstrument fInstrument = new FInstrument();
        fInstrument = new FInstrument();
        fInstrument.setLow(10);
        fInstrument.setOpen(40);
        fInstrument.setClose(40);
        fInstrument.setHigh(70);
        Candle widget = new Candle(fInstrument);
        return new CandlestickWidget(widget, null);
    }

}
